<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding:0;box-sizing: border-box}
        #box{
            width: 100%;
            height: 300px;
            border: solid 1px #999;
        }

        #abc{
            color: #09076b;
        }
    </style>
</head>
<body>
    <div id="box"></div>

    <script>
        let box = document.querySelector('#box');

        //绑定事件
        box.ontouchstart = function(){
            this.style.background = 'rgb(99, 10, 10)';
            // console.log('touchstart');
            this.startTime = Date.now();
        }

        box.onclick = function(){
            // console.log('click');
            this.endTime = Date.now();
            console.log(this.endTime - this.startTime);
        }

        box.ontouchmove = function(){
            this.style.background = '#b7ca09';
            console.log('movemovemove');
        }

        box.ontouchend = function(){
            this.style.background = '#09076b'
        }

        box.ontouchcancel = function(){
            console.log("触摸被打断啦!!!");
        }

        // setTimeout(() => {
        //     alert('主人, 那家伙又来电话了!!');
        // }, 3000);

    </script>
</body>
</html>